﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using Ninject;
using NUtilities;
using Ninject.Conditions;
using Ninject.Parameters;
using NInject_Version2.dataLayer;
using NInject_Version2.configuration;

namespace NInject_Version2
{
  public class MyModule : Ninject.Modules.NinjectModule
  {
    public override void Load()
    {
      Bind<ISettings>().To<Settings>().InSingletonScope();
      Bind<IDataLayer>().To<DataLayer1>().Named("PeanutButter");
      Bind<IDataLayer>().To<DataLayer2>().Named("Jelly");
    }
  }

  public class AdapterServiceProvider 
  {
    private IKernel _kernel = null;
    
    private IDataLayer _dataLayer = null;

    public AdapterServiceProvider(ISettings settings)
    {
      _kernel = new StandardKernel(new MyModule());
      _kernel.Get<ISettings>(new ConstructorArgument("settings", settings));

      _dataLayer = _kernel.Get<IDataLayer>("Jelly");
    }

    public void GetData(string input)
    {
      Console.WriteLine(_dataLayer.GetData(input));
      Console.ReadLine();
    }    
  }
}
